#include <stdio.h>
#include "ofc/DBigInt.h"

int main(int argc, char *argv[])
{
#ifdef HAVE_DBIGINT
  DBigInt *nr1 = [DBigInt alloc];
  DBigInt *nr2 = [DBigInt alloc];
  DBigInt *nr3 = [DBigInt new  ];
  DText   *str;

  [nr1 init :1000];                 // Initialise with an integer number
  [nr2 init :"7000" :10];           // Initialise with a string and a base

  [nr2 mul :nr1];                   // nr2 = nr2 * nr1

  [nr3 sub :nr2 :nr1];              // nr3 = nr2 - nr1

  printf("Value (as long):%ld\n", [nr3 get]);

  str = [nr3 get :10];              // Convert to a string, base 10
  printf("Value (as string):%s\n", [str cstring]);

  if ([nr1 compare :nr2] == 0)      // Compare numbers
    printf("Int1 is equal to int2\n");
  else if ([nr1 compare :nr2] < 0)
    printf("Int1 is smaller than int2\n");
  else
    printf("Int1 is greater than int2\n");

  [str free];                       // Cleanup 
  [nr3 free];
  [nr2 free];
  [nr1 free];
#else
  printf("DBigInt is not present in the library.\n");
#endif
  return 0;
}

